package com.ithei.多线程第二天.原子性;

import java.util.concurrent.atomic.AtomicInteger;

public class Demo2 {
    public static void main(String[] args) {
        AtomicInteger ai=new AtomicInteger(10);
        int i = ai.get();
        System.out.println(i);
        System.out.println(ai);
        System.out.println("====================");
        int andIncrement = ai.getAndIncrement();
        System.out.println(andIncrement);
        System.out.println(ai);
        System.out.println("====================");
        int i1 = ai.incrementAndGet();
        System.out.println(i1);
        System.out.println(ai);
        System.out.println("====================");
        int i2 = ai.addAndGet(20);
        System.out.println(i2);
        System.out.println(ai);
        System.out.println("====================");
        int andSet = ai.getAndSet(22);
        System.out.println(andSet);
        System.out.println(ai);
        System.out.println("====================");
        AtomicInteger demo=new AtomicInteger(22);
        int andIncrement1 = demo.getAndIncrement();
        System.out.println(andIncrement1);
        System.out.println(demo);
        System.out.println("====================");
        int i3 = demo.incrementAndGet();
        System.out.println(i3);
        System.out.println(demo);
        System.out.println("====================");

        System.out.println("====================");


        System.out.println("====================");

    }
}
